<div ng-controller="AssignRoomCtrl">
<div class="panel panel-default">

 	<div class="panel-body" style="padding-top: 0;padding-bottom: 0;">                 
  		<div class="nav navbar-nav m-t"> 
            <a ui-sref="app.sys.devicelist({dpage:'{{$state.params.anpage}}',pid:'{{$state.params.pid}}',pname:aaData.product_name})" ><span style="background-color: #e0e0e0; text-align: center;"><i class="glyphicon glyphicon-arrow-left" style="height:30px;width:30px; "></i></span></a>  			            
            <span><b>系统设置</b></span>
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>产品管理</b> </span>
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>设备列表</b></span> 
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>分配房间</b></span> 
         </div>
        <!-- nabar right -->
        <ul class="nav navbar-nav navbar-right">          
          <li class="dropdown" dropdown>
            <a href class="dropdown-toggle clear" dropdown-toggle>
              <span class="thumb-sm avatar pull-right m-t-n-sm m-b-n-sm m-l-sm">
                <img src="img/a0.jpg" alt="...">
                <i class="on md b-white bottom"></i>
              </span>
              <span class="hidden-sm hidden-md"><b>{{namedata}}</b></span> <b class="caret"></b>
            </a>
            <!-- dropdown -->
            <ul class="dropdown-menu animated fadeInRight w">  
              <li>
                <a ui-sref="app.user.info">用户信息</a>
              </li>       
              <li class="divider"></li>
              <li>
                <a ui-sref="access.signin" ng-click="logout()">登出</a>
              </li>
            </ul>
            <!-- / dropdown -->
          </li>
        </ul>
 	</div>
</div>
<div class="panel m-t-n-md">
  <div class="panel-body">
    <div class="row">
      <div class="col-md-6">
        <h4><b>设备信息</b></h4>
        <table class="table">
          <tr>
            <td>
              <div class="form-group">
                <label class="col-md-3 control-label">设备编号：</label>
                <div class="col-md-9" >
                    <label  control-label">{{aaData.equipment_snumber}}</label>                       
                </div>     
              </div>
            </td>
            
          </tr>
           <tr>
            <td>           
              <div class="form-group">
                <label class="col-md-3 control-label">产品名称：</label>
                <div class="col-md-9" >
                    <label  control-label">{{aaData.product_name}}</label>                       
                </div>     
              </div>
            </td>            
          </tr>
          <tr>
            <td>
               <div class="form-group">
                <label class="col-md-3 control-label">MAC地址：</label>
                <div class="col-md-9" >
                    <label  control-label">{{aaData.mac_address}}</label>                       
                </div>     
              </div>
            </td>
            
          </tr>
           <tr>
            <td>
              <div class="form-group">
                <label class="col-md-3 control-label">设备名称 ：</label>
                <div class="col-md-9" >
                    <label  control-label">{{aaData.equipment_name}}</label>                       
                </div>     
              </div>
           </td>
            
          </tr>
          <tr>
            <td>
              <div class="form-group">
                <label class="col-md-3 control-label">设备品牌：</label>
                <div class="col-md-9" >
                    <label  control-label">{{aaData.brand}}</label>                       
                </div>     
              </div>
            </td>            
          </tr>
          
        </table>
      </div>
      <div class="col-md-6">
        <h4><b>楼层分配</b></h4>        
        <table class="table">
          <tr>
           <td>
             <div class="form-group">
                <label class="col-md-3 control-label">请选择学校：</label>
                <div class="col-md-9" >
                  <select class="form-control" ng-model="bb.school_name"  ng-change="bb.buildingtype='';bb.building_name='';bb.layer_name='';" >
                    <option value="">--请选择学校--</option>
                    <option ng-if="key!='所有学校'" ng-repeat="(key,value) in layerData">{{key}}</option>                 
                  </select>                 
                </div>     
              </div>
           </td>
          </tr>
          <tr>
            <td>
              <div class="form-group">
                <label class="col-md-3 control-label">请选择楼类型：</label>
                <div class="col-md-9" >
                    <select class="form-control" ng-model="bb.buildingtype"  ng-change="bb.building_name='';bb.layer_name='';">
                      <option value="">--请选择类型--</option>
                      <option ng-if="key!='school_id'&&key!='school_name'&&key!='undefined'&&key!='所有类型'" ng-repeat="(key,value) in layerData[bb.school_name]" value="{{key}}+{{layerData[bb.school_name].school_id}}">{{key}}</option >
                    </select>                  
                </div>     
              </div>
            </td>
           
          </tr>
          <tr>
            <td>
              <div class="form-group">
                <label class="col-md-3 control-label">请选择楼号：</label>
                <div class="col-md-9" >
                    <select class="form-control" ng-model="bb.building_name"  ng-change="bb.layer_name=''">
                      <option value="">--请选择楼号--</option>
                      <option ng-if="key!='所有楼'" ng-repeat="(key,value) in layerData[bb.school_name][bb.buildingtype.split('+')[0]]">{{key}}</option>                  
                      
                    </select>                     
                </div>     
              </div>
            </td>
           
          </tr>
          <tr>
            <td>
              <div class="form-group">
                <label class="col-md-3 control-label">请选择楼层：</label>
                <div class="col-md-9" >
                   <select class="form-control" ng-model="bb.layer_name" >
                      <option value="">--请选择楼层--</option>
                     <!--  <option value="{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+所有层">所有层</option> -->
                      <option ng-if="value!='所有层'"  ng-repeat="(key,value) in layerData[bb.school_name][bb.buildingtype.split('+')[0]][bb.building_name].layers" value="{{value.layer_name}}+{{layerData[bb.school_name][bb.buildingtype.split('+')[0]][bb.building_name].campus_id}}+{{value.layer_id}}">                
                        {{value.layer_name}}
                      </option>
                      
                    </select>                     
                </div>     
              </div>
            </td>
           
          </tr>
        </table>
      </div>
    </div>
    <div class="">
        <div style="font-weight: bold;font-size: 18px;">
          宿舍分配
        </div>       
        <table class="table m-t" style="font-size: 14px">
            <tr>
              <td>请选择学校</td>
              <td>请选择类型</td>
              <td>请选择楼号</td>
              <td>请选择楼层</td>
              <th>请选择寝室</th>
              <td></td>
            </tr>
            <tr>
              <td>
                <select class="form-control" ng-model="b.school_name" ng-change="b.buildingtype='';b.building_name='';b.layer_name='';" >
                  <option value="">--请选择学校--</option>
                  <option ng-if="key!='所有学校'" ng-repeat="(key,value) in layerData">{{key}}</option>                 
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.buildingtype"  ng-change="b.building_name='';b.layer_name='';">
                  <option value="">--请选择类型--</option>
                  <option ng-if="key!='school_id'&&key!='school_name'&&key!='undefined'&&key!=''&&key!='所有类型'" ng-repeat="(key,value) in mmData[b.school_name]" value="{{key}}+{{mmData[b.school_name].school_id}}">{{key}}</option >
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.building_name" ng-change="getrooms(mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id) ">
                  <option value="">--请选择楼号--</option>
                  <option ng-if="key!='所有楼'" ng-repeat="(key,value) in layerData[bb.school_name][bb.buildingtype.split('+')[0]]">{{key}}</option>                                    
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.layer_name" >
                  <option value="">--请选择楼层--</option>
                 <!--  <option value="{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+所有层">所有层</option> -->
                  <option ng-if="value!='所有层'"  ng-repeat="(key,value) in mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].layers" value="{{value.layer_name}}+{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+{{value.layer_id}}">                
                    {{value.layer_name}}
                  </option>
                  
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.room_name" ng-options="value.room_name+','+value.room_id as value.room_name for (key,value) in roomData[b.layer_name.split('+')[0]]">
                  <option value="">--请选择单元--</option>                
                </select>
              </td>
              <td>
                <button class="btn btn-sm btn-rounded" ng-click="add()">添加</button>
              </td>
            </tr>           
          </table>

          <div style="font-weight: bold;font-size: 18px;" class="m-t">
            所选寝室
          </div>
          <table class="table">
              <tr>
                <th>学校</th>
                <th>类型</th>
                <th>楼号</th>
                <th>楼层</th>
                <th>单元</th>
                <th></th>
              </tr>
              <tr ng-repeat="aa in nn track by $index">
                <td>{{aa.school_name}}</td>
                <td>{{aa.buildingtype}}</td>               
                <td>{{aa.building_name}}</td>                             
                <td>{{aa.layer_name}}</td>               
                <td>{{aa.room_name}}</td>
                <td>
                  <button class="btn btn-xs btn-danger btn-rounded" ng-click="del('{{$index}}')">删除</button>
                </td>
              </tr>
          </table>         

             <div class="text-center">
              <button class="btn btn-rounded" ng-click="saveassignroom()">保存</button>
            </div> 
    </div>
  </div>
</div>
